﻿@model int
<form id="fileUpload" enctype="multipart/form-data">
        @(Html.X().FormPanel()
            .ID("BasicForm")
            .Width(500)
            .Frame(true)
            .Title("File Upload Form")
            .PaddingSpec("10px 10px 0 10px")
            .FieldDefaults(fd => fd.LabelWidth = 50)
            .Defaults(d => {
                    d.Add(new Parameter("anchor", "95%", ParameterMode.Value));
                    d.Add(new Parameter("allowBlank", "false", ParameterMode.Raw));
                    d.Add(new Parameter("msgTarget", "side", ParameterMode.Value));
            })
            .Items(
                Html.X().TextField()
                    .ID("PhotoName")
                    .FieldLabel("Name"),
                
                Html.X().FileUploadField()
                    .ID("FileUploadField1")
                    .EmptyText("Select an image")
                    .FieldLabel("Photo")
                    .ButtonText("")
                    .Icon(Icon.ImageAdd)
            )
            .Listeners(l => l.ValidityChange.Handler = "#{SaveButton}.setDisabled(!valid);")
            .Buttons(
                Html.X().Button()
                    .ID("SaveButton")
                    .Text("Save")
                    .Disabled(true)
                    .DirectEvents(de => {
                        de.Click.Url = Url.Action("UploadClick");
                        de.Click.FormID = "fileUpload";
                        de.Click.Before = @"if (!#{BasicForm}.getForm().isValid()) { return false; } 
                            Ext.Msg.wait('Uploading your photo...', 'Uploading');";
                        de.Click.Failure = @"Ext.Msg.show({ 
                                title   : 'Error', 
                                msg     : 'Error during uploading', 
                                minWidth: 200, 
                                modal   : true, 
                                icon    : Ext.Msg.ERROR, 
                                buttons : Ext.Msg.OK 
                            });";
                    }),
                
                Html.X().Button()
                    .Text("Reset")
                    .OnClientClick("#{BasicForm}.getForm().reset();")
            )
        )
    </form>
@*@(Html.X().FormPanel()
            .ID("BasicForm")
            .Width(500)
            .Frame(true)
            .Title("File Upload Form")
            .PaddingSpec("10px 10px 0 10px")
            .FieldDefaults(fd => fd.LabelWidth = 50)
            .Defaults(d => {
                    d.Add(new Parameter("anchor", "95%", ParameterMode.Value));
                    d.Add(new Parameter("allowBlank", "false", ParameterMode.Raw));
                    d.Add(new Parameter("msgTarget", "side", ParameterMode.Value));
            })
            .Items(
                Html.X().TextField()
                    .ID("PhotoName")
                    .FieldLabel("Name"),
                
                Html.X().FileUploadField()
                    .ID("FileUploadField1")
                    .EmptyText("Select an image")
                    .FieldLabel("Photo")
                    .ButtonText("")
                    .Icon(Icon.ImageAdd)
            )
            .Listeners(l => l.ValidityChange.Handler = "#{SaveButton}.setDisabled(!valid);")
            .Buttons(
                Html.X().Button()
                    .ID("SaveButton")
                    .Text("Save")
                    .Disabled(true)
                    .DirectEvents(de => {
                        de.Click.Url = Url.Action("UploadClick");
                        de.Click.FormID = "fileUpload";
                        de.Click.Before = @"if (!#{BasicForm}.getForm().isValid()) { return false; } 
                            Ext.Msg.wait('Uploading your photo...', 'Uploading');";
                        de.Click.Failure = @"Ext.Msg.show({ 
                                title   : 'Error', 
                                msg     : 'Error during uploading', 
                                minWidth: 200, 
                                modal   : true, 
                                icon    : Ext.Msg.ERROR, 
                                buttons : Ext.Msg.OK 
                            });";
                    }),
                
                Html.X().Button()
                    .Text("Reset")
                    .OnClientClick("#{BasicForm}.getForm().reset();")
            )
        )*@